package p1200;

import java.util.HashMap;
import java.util.Map;

public class Leetcode_1299 {
    public int[] replaceElements(int[] arr) {
        int max = arr[arr.length - 1];
        arr[arr.length - 1] = -1;
        if (arr.length <= 1) {
            return new int[]{-1};
        }
        for (int i = arr.length - 2; i >= 0; i--) {
            int temp = arr[i];
            arr[i] = max;
            if (max <temp) {
                max = temp;
            }
        }
        return arr;
    }
}
